import { fetch_get, fetch_post } from '@/api/network';

export async function userLogin() {
  await fetch_post('/login', {}, {
    params: {
      username: '202107151111',
      password: '2021071511115170',
    },
  });
  sessionStorage.username = 1;
  sessionStorage.password = 11;
}

export interface userInfoRe {
    姓名: string;
    用户名: number;
    站号: number;
    站名: string;
    当前班名: string;
    当前班号: number;
    私账比例: number;
    站编号: number;
    上个交班时间: string
    可见比例: number;
    角色菜单: string[];
    审核控制: string[];
    角色编号: number;
    角色名称: string;
}

export interface oilsRiseType {
  日期: any,
  油品: any,
  升数: any,
  油机金额: any,
  实收金额: any
}

/** 油品销售升数与数量* */
export async function getOilsRise(stationCode: number, startDate: string, endDate: string): Promise<oilsRiseType[]> {
  const data = await fetch_get('/analysis/oilSalesData2', {
    method: 'GET',
    params: { stationNo: stationCode, startDate, endDate },
  });
  return data;
}

export interface realTimeSaleType {
    油品: any,
    升数: any,
    '油机金额（移动支付）': any,
    '实收金额（移动支付）': any,
    '优惠金额（移动支付）': any,
    '油机金额（现金）': any,
    '实收金额（现金）': any,
    '优惠金额（现金）': any,
}

/** 油品营收金额* */
export async function getRealTimeSale(stationCode: number, startDate: string, endDate: string): Promise<realTimeSaleType[]> {
  const data = await fetch_get('/analysis/oilIncomeAmount2', {
    method: 'GET',
    params: { stationNo: stationCode, startDate, endDate },
  });
  return data;
}

export interface oilsSummaryType {
    便利店单数: any,
    油品订单数: any,
    客单价: any,
    '区间实收金额(元)': any,
    '区间优惠金额(元)': any,
    '区间油机金额(元)': any,
    '地磅收入': any,
    '站号': any,
    '本年度油机金额(万元)': any,
    '便利店(元)': any,
    '区间销售量(升)': any,
    '本年度实收金额(万元)': any,
    '本年度销售量(吨)': any,
    '本年度优惠总额(万元)': any,
    '订单均价': any
}

/** 实时营收* */
export async function getOilsSummaryData(startDate: string, endDate: string, stationCode: number, type: number): Promise<oilsSummaryType[]> {
  const data = await fetch_get('/analysis/dynamicIncome2', {
    method: 'GET',
    params: {
      startDate, endDate, stationNo: stationCode, type,
    },
  });
  return data;
}

export interface serviceAreaType {
    升数: any,
    服务区: any
}

/** 油站销量排行* */
export async function getServiceArea(): Promise<serviceAreaType[]> {
  const data = await fetch_get('/analysis/stationSalesRank', { method: 'GET', params: { stationNo: -1 } });
  return data;
}

export interface opwRealTimeType {
    站号: any,
    站名: any,
    罐号: any,
    油品编号: any,
    油品名称: any,
    油积: any,
    标积: any,
    空积: any,
    油高: any,
    水高: any,
    温度: any,
    水积: any
}

/** 液位仪监控* */
export async function opwRealTimeData(stationCode: number): Promise<opwRealTimeType[]> {
  const data = await fetch_get('/analysis/dynamicTankLiquid', {
    method: 'GET',
    params: { stationNo: stationCode },
  });
  return data;
}

export interface monetaryTrendType {
    '日期1': any,
    '升数1': any,
    '油机金额1': any,
    '日期2': any,
    '升数2': any,
    '油机金额2': any
}

/** 消费走势(周月年)* */
export async function monetaryTrend(stationCode: number, queryType: number): Promise<monetaryTrendType[]> {
  const data = await fetch_get('/analysis/consumeTrend', {
    method: 'GET',
    params: { stationNo: stationCode, queryType },
  });
  return data;
}

export interface saleProportionType {
    油品: any,
    油机金额: any
}

/** 营收占比* */
export async function saleProportion(stationCode: number): Promise<saleProportionType[]> {
  const data = await fetch_get('/analysis/incomeRank', { method: 'GET', params: { stationNo: stationCode } });
  return data;
}

export interface stationType {
    站号: any,
    站名: any
}

/** 所有油站* */
export async function allStation(): Promise<stationType[]> {
  const data = await fetch_get('/analysis/stationList', { method: 'GET', params: { stationNo: -1, queryType: 1 } });
  return data;
}

export interface consumeTrendType {
    时间: any,
    油机金额: any
}

/** 今日走势图(消费金额)* */
export async function consumeTrend(stationCode: number, type: number, startDate: string, endDate: string): Promise<consumeTrendType[]> {
  const data = await fetch_get('/analysis/todayConsume2', {
    method: 'GET',
    params: {
      stationNo: stationCode, type, startDate, endDate,
    },
  });
  return data;
}

export interface paymentStatisticsType {
    收款方式: any,
    升数: any,
    金额: any,
    实收金额: any,
    笔数: any
}

/** 支付方式统计* */
export async function paymentStatistics(stationCode: number, startDate: string, endDate: string): Promise<paymentStatisticsType[]> {
  const data = await fetch_get('/analysis/paymentStatistic2', {
    method: 'GET',
    params: { stationNo: stationCode, startDate, endDate },
  });
  return data;
}

export interface vipStatusType {
    会员总数: any,
    会员新增: any,
    '区间会员消费总额(万)': any,
    '区间会员平均消费(元)': any

}

/** 会员概况* */
export async function vipStatus(stationNo: number, startDate: string, endDate: string): Promise<vipStatusType[]> {
  const data = await fetch_get('/analysis/vipStatus', {
    method: 'GET',
    params: { stationNo, startDate, endDate },
  });
  return data;
}

/** 登录* */
export async function login(username:any, password:any) {
  return await fetch_post('/login', {}, {
    params: {
      username,
      password: username! + password!,
    },
  });
}

// 请求监控数据
export async function getDynamicMachAndBill(params: any) {
  return await fetch_post('/analysis/dynamicMachAndBill', params);
}

// 请求摄像头地址
export async function getDynamicCamList(params: any) {
  return await fetch_post('/analysis/dynamicCamList', params);
}

// 获取本地ip地址
export async function getInetadress() {
  return await fetch_post('/analysis/getInetadress', {});
}

// 退出登录
export async function logout(username:any) {
  return await fetch_post('/logout', {}, {
    params: {
      username,
    },
  });
}
